<#assign contextPath=springMacroRequestContext.getContextPath()/>
<#import "/public/frame/main.html" as frame/>
<@frame.head "南航明珠商城-赠品活动-添加赠品"></@frame.head>
<link rel="stylesheet" type="text/css" href="${contextPath}/resources/css/search_table.css"/>
<div class="page-container">
	<div class="text-c">
		<form action="${contextPath}/presentActivityController/to_add_present" method="post" name="search_form" id="search_form">
       		<input type="hidden" name="page" value="${pagination.pageNo}" id="page"/>
       		<input type="hidden" name="pWindowName" value="${pWindowName}" id="pWindowName"/> <!-- 调用端窗口的windowname，用于处理返回值时获取调用端的ifreame对象 -->
       		<input type="hidden" name="isShowApplyAllFlag" value="${isShowApplyAllFlag?string}" id="isShowApplyAllFlag"/>
       		<input type="hidden" name="applyAllIsChecked" value="${applyAllIsChecked?string}" id="applyAllIsChecked"/> <!-- 用于翻页时是否选中“应用到其他待选商品” -->
       		<#list excludeIds as id>
			<input type="hidden" name="excludeIds" value="${id}"/>
			</#list>
			<input type="hidden" name="presentIds" id="presentIds" value="${presentIds}"/> <!-- 被选中的赠品ID -->
       		<table class="table search_table" >
				<tr>  
	           		<td>赠品编号：</td>
	           		<td><input class="input-text radius" placeholder="请输入赠品编号" name="presentNo" id="presentNo" value="${presentQo.presentNo}" onkeyup='this.value=this.value.replace(/\D/g,"")'/>
	           		<td>赠品名称：</td>
	           		<td><input class="input-text radius" placeholder="请输入赠品名称" name="presentName" id="presentName" value="${presentQo.presentName}"/></td>   
	           		<td>商户名称：</td>
	           		<td>
			       		<span class="select-box radius">
				           	<select class="select" id="merchantQoId" name="merchantQo.id">
				           		<option value>请选择</option>
				             	<#list merchantNewList as list>  
								<option value="${list.id?c}" <#if list.id==presentQo.merchantQo.id>selected="selected"</#if>>${list.mercName}</option>
				             	</#list>
				           	</select>
	           			</span>
	           		</td>
	           		<td>
	           			<input class="btn btn-success radius" type="button" onclick="search();" value="搜索"/>
	           		</td>
	           		<td>
	           			<input class="btn btn-success radius" type="button" onclick="toIsEmpty();" value="重置"/>
	           		</td>
	         	</tr>
      		</table>
		</form>
	</div>
    <div class="cl pd-5 bg-1 bk-gray mt-20 radius"> 
    	<span class="l">
    		<a href="javascript:;" onclick="addPresent();" class="btn btn-primary radius">确定添加选中赠品</a>
    		<#if isShowApplyAllFlag>
    		&nbsp;&nbsp;<input type="checkbox" id="applyAllFlag" onclick="applyAllClicked(this);" name="applyAllFlag" <#if applyAllIsChecked>checked="checked"</#if> style="cursor: pointer;"/>&nbsp;<lable id="applyAllFlagText" style="color: red;">应用到其他待选商品</lable>
    		</#if>
    	</span>
    	<span class="r">共有数据：<strong>${pagination.totalCount}</strong> 条</span>
    </div>
	<table class="table table-border table-bordered table-bg radius table-hover" style="margin-top: -1px;">
		<thead>
			<tr class="text-c">
				<th style="width:5%;"><input type="checkbox" onclick="selectAll();" id="selectAll" style="cursor: pointer;"/></th>
	            <th style="width:10%;">赠品编号</th>
	            <th style="width:25%;">赠品名称</th>
	            <th style="width:25%;">所属供应商</th>
	            <th style="width:10%;">剩余库存</th>
	            <th style="width:10%;">参考价格</th>
	        </tr>
		</thead>
		<tbody>
         	<#list pagination.list as list> 
			<tr class="text-c">
	            <td><input type="checkbox" name="chk" id="${list.id?c}" value="${list.id?c}" onclick="ckClicked(this);" style="cursor: pointer;"/></td>
	            <td id="id_${list.id?c}">${list.id}</td>
	            <td id="name_${list.id?c}">${list.name}</td>
	            <td id="mercName_${list.id?c}">${list.merchant.mercName}</td>
	            <td id="stock_${list.id?c}">${list.presentStock-list.presentSaleStock}</td>
	            <td id="price_${list.id?c}"><#if list.presentPrice?? && list.presentPrice != "">${list.presentPrice + "里程"}</#if></td>
			</tr>
			</#list>
		</tbody>
    </table>
	<div id="div_page" style="padding-top: 10px;float: right"></div>
</div>
<@frame.end "default"></@frame.end>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/presentActivity/present_list.js"></script>
<script type="text/javascript">
	var path = "${contextPath}";
	var isShowApplyAllFlag = ${isShowApplyAllFlag?string};
	laypage({
	    cont: "div_page", // 容器。值支持id名、原生dom对象，jquery对象。
	    pages: ${pagination.totalPage}, // 通过后台拿到的总页数
	    curr:  ${pagination.pageNo} || 1, // 当前页
		skip: true, // 是否开启跳页
		first: 1, // 将首页显示为数字1,。若不显示，设置false即可
		last: ${pagination.totalPage}, // 将尾页显示为总页数。若不显示，设置false即可
	    jump: function(obj, first){ // 触发分页后的回调
	        if(!first){ // 点击跳页触发函数;当前页为obj.curr
	            $("#page").val(obj.curr);
	            search();
	        }
	    }
	});
</script>